package Background;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import javax.swing.JLabel;
import javax.swing.JPanel;

/**
 * A class to handle the events.
 * @author Justin Sorrel
 *
 */

public class Event {

	public  Calendar date;
	
	public String location;
	
	public String type;
	
	public String name;
	
	private JPanel panel;
	
	public Event() {
		panel = new JPanel();
		panel.setPreferredSize(new Dimension(250,250));
	}
	
	public void setDate(int year, int day, int month) {
		Calendar myCal = Calendar.getInstance();
		myCal.set(Calendar.YEAR, year);
		myCal.set(Calendar.MONTH, month);
		myCal.set(Calendar.DAY_OF_MONTH, day);

		date = myCal;
	}

	public Calendar getDate() {
		return date;
	
	}
	
	public void setName(String the_name) {
		name = the_name;
	}
	
	public String getName() {
		return name;
	}
	
	public void setType(String the_type) {
		type = the_type;
	}
	
	public String getType() {
		return type;
	}
	
	public void setLocation(String the_location) {
		location = the_location;
	}
	
	public String getLocation() {
		return location;
	}
	
	public void makeEvent(Container mY_PANEL) {
		JPanel grid = new JPanel(new GridLayout(4,1));
		JLabel name = new JLabel(getName());
		JLabel type = new JLabel(getType());
		JLabel location = new JLabel(getLocation());
		JLabel date = new JLabel();
		DateFormat df = new SimpleDateFormat("MM/dd/yyyy");

		// Get the date today using Calendar object.
		Date today = Calendar.getInstance().getTime();        
		// Using DateFormat format method we can create a string 
		// representation of a date with the defined format.
		String reportDate = df.format(today);
		date.setText(reportDate);
		grid.add(name);
		grid.add(type);
		grid.add(location);
		grid.add(date);
		panel.add(grid);
		mY_PANEL.add(panel, BorderLayout.EAST);
		
	}
}
